const router = require('koa-router')()
const Mock = require('mockjs')
const { list } = Mock.mock({
  "list|10000": [{
    "id": "@id",
    // "id|+1": 1,
    "image": "@image(150x120, @color)",
    "title": "@ctitle",
    "desc": "@cword(10, 20)",
    "price|10-20": 1,
  }]
})

router.get('/list', ctx => {
  const { pageSize = 10, pageCode = 1 } = ctx.request.query;
  const newList = list.slice((pageCode - 1) * pageSize, pageCode * pageSize);
  ctx.body = {
    code: 200,
    data: newList
  }
})

module.exports = router
